package dao.mapper.auth;

import model.auth.UsersRoles;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.mybatis.spring.annotation.Mapper;

@Mapper("auth.UsersRolesCrudMapper")
public interface UsersRolesCrudMapper {

	@Select("select seq_a_usersroles.nextval from dual")
	long selectKey();
	
	@Insert(" insert into a_users_roles (id, userid, roleid) values (#{m.id}, #{m.userid}, #{m.roleid}) ")
	int insert(@Param("m") UsersRoles model);
	
	@Select("select * from a_usersroles where id=#{id} ")
	UsersRoles getById(@Param("id") Long id);

	@Select("select * from a_usersroles where id=#{id} and enabled=#{enabled}")
	UsersRoles getValidById(@Param("id") Long id, @Param("enabled") Integer enabled);
	
	@Delete("delete from a_usersroles where id=#{id}")
	int deleteById(@Param("id") Long id);
	
}
